home *** CD-ROM | disk | FTP | other *** search
- /*
- mak_cfg.c -- get configuration information
- for the makemak program
- */
-
- /* Last revised : Sun February 21, 1988 at 1:14:57 pm*/
- /* Loran W. Richardson */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "makemak.h"
-
- char defaults[LIBS + 1][SLEN];
- char mak_defs[LIBS + 1][FNAMELEN];
- #define _MAX_PATH 255
-
- int mak_cfg(char *pname)
- {
- char line[SLEN];
- char temp[SLEN];
- char path[_MAX_PATH];
- char *p;
- char *s;
- FILE *fp;
- FLAGS i;
-
- /* set up header strings */
- strcpy(mak_defs[TARGET], "TARGET");
- strcpy(mak_defs[CC], "CC");
- strcpy(mak_defs[C_OPTS], "C_OPTS");
- strcpy(mak_defs[CDEFS] ,"CDEFS");
- strcpy(mak_defs[MC], "MC");
- strcpy(mak_defs[M_OPTS], "M_OPTS");
- strcpy(mak_defs[MDEFS], "MDEFS");
- strcpy(mak_defs[LINK], "LINK");
- strcpy(mak_defs[L_OPTS], "L_OPTS");
- strcpy(mak_defs[LMAP], "LMAP");
- strcpy(mak_defs[LIBS], "LIBS");
-
- /* set up the defaults */
-
- strcpy(defaults[CC], "tcc");
- strcpy(defaults[C_OPTS], "");
- strcpy(defaults[CDEFS], "");
- strcpy(defaults[MC], "masm");
- strcpy(defaults[M_OPTS], "");
- strcpy(defaults[MDEFS], "");
- strcpy(defaults[LINK], "tlink");
- strcpy(defaults[L_OPTS], "");
- strcpy(defaults[LMAP], "NUL");
- strcpy(defaults[LIBS], "");
-
-
-
-
- /* get the environment settings */
- if ((s = getenv("TCC")) != NULL)
- strcpy(defaults[C_OPTS], s);
-
- if ((s = getenv("MASM")) != NULL)
- strcpy(defaults[M_OPTS], s);
-
- if ((s = getenv("TLINK")) != NULL)
- strcpy(defaults[L_OPTS], s);
-
- /* get the configuration file values */
- /* _searchenv("makemak.cfg", "CONFIG", path); /* find the configuration file */
- p = searchpath("makemak.cfg");
- strcpy(path, p);
-
- if (path[0] != '\0')
- if ((fp = fopen(path, "r")) != NULL)
- while ((s = fgets(line, SLEN, fp)) != NULL) /* read in a line */
- {
- strcpy(temp, strtok(line, " \t\n=")); /* get the first word */
- for (i = CC; i <= LIBS; ++i) /* loop through the options */
- if (strcmpi(temp, mak_defs[i]) == 0) /* word matches option ? */
- {
- strcpy(defaults[i], strtok(NULL, "\n")); /* copy the rest of the line */
- if (defaults[i][0] == '=') /* into the defaults */
- strcpy(defaults[i], (defaults[i]) + 1);
- break;
- }
- }
- return(0);
- }
-